﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>down2-vue示例</title>
    <script type="text/javascript" src="js/jquery-1.4.min.js"></script>
    <script type="text/javascript" src="js/down.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/vue.min.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/down.vue.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/demo.js" charset="utf-8"></script>
    <style type="text/css">
        h5 {margin:0;font-family: 微软雅黑 宋体;}
        p {font: 9pt 宋体;}
        ul {list-style-type: none;font: 9pt 宋体;}
        ul li {display: inline;margin: 0 5px 0 0;font: 9pt 宋体;}
    </style>
</head>
<body>
    <h5>vue组件</h5>
    <div id="demos"></div>
    <div id="app">
        <!--ui-->
        <input type="button" value="下载测试文件" @click="down_urls" />
        <!--上传面板-->
        <down2 ref="down2"
               :config="config.down2"
               @task_create="down2_create_task"
               @folder_sel="down2_folderSel"
               @file_append="down2_file_append"
               @queue_complete="down2_queue_complete"
               @load_complete="down2_load_complete"
               @unsetup="down2_unsetup" />
    </div>
    <script type="text/javascript" language="javascript">
        //根路径：http://localhost/api/up6/
        var pos = window.location.href.lastIndexOf("/");
        var root = [
            window.location.href.substr(0, pos + 1),
            "db/"
        ].join("");

        //创建vue对象
        var ue = new Vue({
            el: '#app',
            data: {
                downApp: null,
                config: {
                    down2: {
                        License2: "",
                        //可扩展的业务逻辑字段
                        Fields: { uid: 0 },
                        //后端接口-文件
                        "UrlCreate": root + "d_create.aspx",
                        "UrlDel": root + "d_del.aspx",
                        "UrlList": root + "d_list.aspx",
                        "UrlUpdate": root + "d_update.aspx",
                        "UrlDown": root + "down.aspx"
                    }
                }
            }
            , methods: {
                down_urls: function () {
                    var urls = [
                        { fileUrl: "http://res2.ncmem.com/res/images/ie11.png", fields: { auto: "1" } },
                        { fileUrl: "http://res2.ncmem.com/res/images/up6.1/down.png", fields: { auto: "1" } },
                        { fileUrl: "http://res2.ncmem.com/res/images/firefox.png", fields: { auto: "1" } },
                        { fileUrl: "http://res2.ncmem.com/res/images/edge.png", fields: { auto: "1" } },
                        { fileUrl: "http://res2.ncmem.com/res/images/up6.1/cloud.png", fields: { auto: "1" } },
                        { fileUrl: "http://res2.ncmem.com/res/images/home/w.png", fields: { auto: "1" } },
                        { fileUrl: "http://res2.ncmem.com/res/images/img.png" }
                    ];
                    if (this.downApp.Config["Folder"] == "") {
                        this.downApp.data.urls = urls;
                        this.downApp.openFolder();
                        return;
                    }
                    this.downApp.addUrls(urls);
                },
                down2_folderSel: function (dir) {
                    var app = this.downApp;
                    setTimeout(function () {
                        if (app.data.cur != null) {
                            app.addUrl(downer.data.cur);
                        }
                        if (app.data.urls != null) {
                            app.addUrls(app.data.urls);
                        }
                        app.data.cur = null;
                        app.data.urls = null;
                    }, 100);
                },
                down2_create_task: function (f) {
                    var app = this.downApp;
                    setTimeout(function () {
                        //自动下载
                        if (f.fields.auto == "1") app.start_queue();
                    }, 300);
                },
                down2_file_append: function (o) { },
                down2_unsetup: function () { },
                down2_queue_complete: function () { },
                down2_load_complete: function () { }
            }
            , mounted: function () {
                this.downApp = this.$refs.down2.app;
            }
        });
    </script>
</body>
</html>